//
//  ViewController.m
//  Touch Detector
//
//  Created by iD Student on 7/11/13.
//  Copyright (c) 2013 Apple Inc. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController


- (void) touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint touchPoint = [touch locationInView:self.view];
    NSLog([NSString stringWithFormat:@"touchesBegan, output Touch began at location X:%f Y:%f", touchPoint.x, touchPoint.y]);
    _touchBeganX.text = [NSString stringWithFormat:@"%f", touchPoint.x];
    _touchBeganY.text = [NSString stringWithFormat:@"%f", touchPoint.y];
    
}

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint touchPoint = [touch locationInView:[self view]];
        NSLog(@"touchesEnded, output Touch released from X:%f Y:%f", touchPoint.x, touchPoint.y);
    _touchEndedX.text = [NSString stringWithFormat:@"%f", touchPoint.x];
    _touchEndedY.text = [NSString stringWithFormat:@"%f", touchPoint.y];
}

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint currentTouchpoint = [touch locationInView:[self view]];
    CGPoint previousTouchPoint = [touch previousLocationInView:[self view]];
    NSLog(@"touchesMoved, output Touch moved from X:%f Y:%f to X:%f Y:%f", previousTouchPoint.x, previousTouchPoint.y, currentTouchpoint.x, previousTouchPoint.y );
}


- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [_touchBeganX release];
    [_touchBeganY release];
    [_touchEndedX release];
    [_touchEndedY release];
    [super dealloc];
}
@end